package com.itheima.dao;

import com.itheima.pojo.OrderSettingEdit;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.Date;
import java.util.Map;

@Mapper
public interface OrderSettingMapper {

    void editNumberByOrderDate(OrderSettingEdit orderSettingEdit);

    /**
     * 根据日期查询预约设置
     * @param map
     */
    void getOrderSettingByMonth(Map map);

    /**
     * 根据日期查询已预约人数
     * @param orderDate
     */
    @Select("select reservations from itcast_health.t_ordersetting where orderDate = #{orderDate}")
    Integer getOrderReservationsByOrderDate(Date orderDate);

    /**
     * 根据日期查询可预约人数
     * @param orderDate
     * @return
     */
    @Select("select number from itcast_health.t_ordersetting where orderDate = #{orderDate}")
    Integer getNumberByOrderDate(Date orderDate);

    /**
     * 根据日期更新已预约人数
     * @param orderDate
     */
    @Select("update itcast_health.t_ordersetting set reservations = reservations + 1 where orderDate = #{orderDate}")
    void editReservationsByOrderDate(Date orderDate);
}
